package com.snaildesign.lrc.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.snaildesign.common.DAOException;
import com.snaildesign.common.dao.impl.BaseDAOImpl;
import com.snaildesign.common.util.ConnectionPool;
import com.snaildesign.common.util.DatabaseUtil;
import com.snaildesign.lrc.dao.LrcDAO;
import com.snaildesign.lrc.model.Lrc;
import com.snaildesign.samples.model.Sample;

public class LrcDAOImpl extends BaseDAOImpl implements LrcDAO {
	private static Logger logger = Logger.getLogger(LrcDAOImpl.class.getName());
	
	private DatabaseUtil dbUtil = null;
	ConnectionPool pool = null;

	public LrcDAOImpl(){
		dbUtil = new DatabaseUtil();
		pool = ConnectionPool.getInstance();
	}

	public List<Sample> findLrcByLrcId(String lrcId) throws DAOException {
		List result = new ArrayList();
		Connection connection = pool.getConnection();
		dbUtil.setConnection(connection);
        ResultSet rs = dbUtil.executeQuery("SELECT * FROM sample l ");
        try {
			result = DatabaseUtil.populate(rs, Sample.class);
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
        try {
			rs.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        pool.release(connection);
        
		return result;
	}

	public List<Lrc> findLrcByName(String songName) throws DAOException {
		// TODO Auto-generated method stub
		return null;
	}
}
